package com.rc.saas.mini.service.invoice;

import com.rc.saas.mini.mapper.invoice.InvoiceOrderMapper;
import com.rc.saas.mini.model.invoice.InvoiceOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author wangzhengwei
 * @create 2021/4/28
 */
@Service
public class InvoiceOrderServiceImpl implements InvoiceOrderService {
    @Autowired
    private InvoiceOrderMapper invoiceOrderMapper;

    @Override
    public InvoiceOrderMapper getMapper() {
        return invoiceOrderMapper;
    }

    @Override
    public void insertByCondition(Long invoiceApplyId, String tenantCode, List<Long> orderIds, Long memberId, String updateFlag, Long invoiceId) {
        InvoiceOrder invoiceOrder = new InvoiceOrder();
        for (Long orderId:orderIds){
            invoiceOrder.setOrderId(orderId);
            invoiceOrder.setMemberId(memberId);
            invoiceOrder.setInvoiceId(invoiceId);
            invoiceOrder.setTenantCode(tenantCode);
            invoiceOrder.setInvoiceApplyId(invoiceApplyId);
            invoiceOrder.setUpdateFlag(updateFlag);
            invoiceOrder.setCreatedBy(String.valueOf(memberId));
            invoiceOrder.setCreatedTime(new Date());
            invoiceOrder.setLastUpdatedBy(String.valueOf(memberId));
            invoiceOrder.setLastUpdatedTime(new Date());
            invoiceOrderMapper.insertSelective(invoiceOrder);
        }
    }
}
